﻿
Partial Class store_UCSermon
    Inherits System.Web.UI.UserControl


    Public Sub Display(p As CProduct)
        lblDate.Text = p.DateString
        lblDate.ToolTip = CUtilities.Timespan(p.ProductCreated)
        lnkName.Text = String.Concat(p.ProductName)
        lnkName.NavigateUrl = CSitemap.Decide(p)

        lnkMp3.NavigateUrl = CSitemap.Decide(p)
        lnkMp3.ToolTip = p.ProductName
        With p.Files
            If .HasMp3 Then
                lnkMp3.NavigateUrl = CConfig.DropboxUrl(.FirstMp3.FileName)
                lnkMp3.ToolTip = .FirstMp3.FileNameAndSize
            Else
                lnkMp3.Enabled = False
                lnkMp3.Font.Italic = True
                lnkMp3.ForeColor = Drawing.Color.LightGray
                lnkMp3.ToolTip = "Not Available"
            End If

            If .HasHtm Then
                lnkHtm.NavigateUrl = CSitemap.Decide(p) & "#notes" 'CConfig.DropboxUrl(.FirstHtm.FileName)
                lnkHtm.ToolTip = .FirstHtm.FileNameAndSize
            ElseIf .HasPdfOrWord AndAlso p.IsFree Then
                lnkHtm.NavigateUrl = CConfig.DropboxUrl(.FirstPdfOrWord.FileName)
                lnkHtm.ToolTip = .FirstPdfOrWord.FileNameAndSize
            Else
                lnkHtm.Visible = False
                lnkMp3.Enabled = True
            End If
        End With

        lnkDeaf.NavigateUrl = CSitemap.Decide(p) & "#transcript"
        lnkDeaf.Visible = p.HasTranscript

        lnkVideo.Visible = p.HasVideos
        lnkVideo.NavigateUrl = CSitemap.Decide(p) & "#video"

        lnkPhotos.Visible = p.DuncanPhotos.Count > 0
        lnkPhotos.NavigateUrl = CSitemap.Decide(p) & "#photos"


        litDescription.Text = Server.HtmlEncode(CUtilities.Truncate(p.ProductDescription, 450)).Replace(vbCrLf, "<br>")
        litDescription.ToolTip = p.ProductDescription 'More room, if theres a description
        lblDate.Text = String.Concat(p.SpeakerNames, IIf(True OrElse litDescription.Text.Length = 0, "<br/>", " - "), lblDate.Text) ', "<br/>", p.LocationName)
        'lnkImg.NavigateUrl = lnkName.NavigateUrl
        'lnkImg.ToolTip = p.ProductName
        If p.HasImage Then
            img.ImageUrl = CSitemap.ProductThumb(p)
        Else
            img.ImageUrl = p.Speaker.RandomPhotoUrl(CSitemap.SpeakerUploads & p.Speaker.SpeakerImage, p.ProductId) '  p.Speaker.RandomPhotoUrl(p.Speaker.RandomPhotoUrl(CSitemap.SpeakerUploads & p.Speaker.SpeakerImage, p.ProductId))
            'ElseIf Not String.IsNullOrEmpty(p.Speaker.SpeakerImage) Then
            '    img.ImageUrl = CSitemap.SpeakerUploads & p.Speaker.SpeakerImage
        End If


        lnkName.ToolTip = p.ProductName

        lblLanguage.Text = String.Concat(p.LanguageName, " ", p.LanguageNative)
        If p.ProductLanguageId = ELanguage.English Then lblLanguage.Visible = False


        lnkName2.NavigateUrl = lnkName.NavigateUrl
        lnkName2.ToolTip = lnkName.ToolTip
    End Sub


End Class

